function hexStringToBuffer(hexString) {
    // 将16进制字符串转换为Buffer
    return Buffer.from(hexString.replace(/\s+/g, ''), 'hex');
}
function crc32(hexString) {
    const buffer = hexStringToBuffer(hexString);
    let crc = 0xFFFFFFFF;

    for (let i = 0; i < buffer.length; i++) {
        crc ^= buffer[i];
        for (let j = 0; j < 8; j++) {
            if (crc & 1) {
                crc = (crc >>> 1) ^ 0xEDB88320;
            } else {
                crc = crc >>> 1;
            }
        }
    }

    crc = (~crc) >>> 0;
    return crc.toString(16).padStart(8, '0'); // 转换为16进制字符串并补足8位
}
function calculateCrc32(hexString) {
    const crc32Value = crc32(hexString);
    return crc32Value.toString(16).padStart(8, '0'); // 转换为16进制字符串并补足8位
}

// 示例
const hexString = "00 00 00 00 00 40 00 00 BC 29 00 00 F0 C0 0F 84 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF";
console.log("输入内容:", hexString);

const crc32Result = calculateCrc32(hexString);
console.log("计算结果:", crc32Result.toUpperCase()); // 应输出: A5A86013